home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / src / Tools / freeWAIS-sf-1.1 / ctype / ctest.c next >
Encoding:
C/C++ Source or Header  |  1994-12-06  |  2.5 KB  |  88 lines

  1. /*                               -*- Mode: C -*- 
  2.  * test.c -- 
  3.  * ITIID           : $ITI$ $Header $__Header$
  4.  * Author          : Ulrich Pfeifer
  5.  * Created On      : Wed Mar 23 11:29:46 1994
  6.  * Last Modified By: Ulrich Pfeifer
  7.  * Last Modified On: Tue Dec  6 17:24:47 1994
  8.  * Update Count    : 53
  9.  * Status          : Unknown, Use with caution!
  10.  */
  11.  
  12. #ifdef ORIGINAL
  13. #include <ctype.h>
  14. extern unsigned char _lchars_[];
  15. extern unsigned char _uchars_[];
  16. #define THISCTYPEVAR _ctype_
  17. #else
  18. #define THISCTYPEVAR _fw_ctype_
  19. #include "./ctype.h"
  20. #endif
  21. #include "../ir/cdialect.h"
  22. #include <stdio.h>
  23.  
  24. main()
  25. {
  26.   unsigned char *t;
  27.  
  28.   int c;
  29.   for (c='\0';c<=255;c++) {
  30.     /*if ( THISCTYPEVAR[c+1]) */
  31.       printf("%c %c %c %d %d %d %d %d %d %d %d %d %d %d\n",
  32.              c,
  33.              toupper(c),
  34.              tolower(c),
  35.              isalnum(c),
  36.              isalpha(c),
  37.              iscntrl(c),
  38.              isdigit(c),
  39.              isgraph(c),
  40.              islower(c),
  41.              isprint(c),
  42.              ispunct(c),
  43.              isspace(c),
  44.              isupper(c),
  45.              isascii(c));
  46.   }
  47.  
  48.   printf("Testing lower case letters\n");
  49.   for (t=_lchars_;*t;t++) {
  50.     printf("_fw_ctype_[%d]=%d\t",*t, ((THISCTYPEVAR + 1)[(unsigned char)*t]));
  51. #ifdef DEBUG
  52.     printf("index(%s,%c)=%d\t", _lchars_, *t, 
  53.            index(_lchars_,(unsigned char)(*t))-(char *)_lchars_);
  54. #endif
  55.     printf("islower(%c)=%d\t", *t, islower(*t));
  56.     printf("toupper(%c)=%c\t", *t, toupper(*t));
  57.     printf("isupper(%c)=%d\t", *t, isupper(*t));
  58. #ifdef DEBUG
  59.     printf("index(%s,%c)=%d\t", _uchars_, *t, 
  60.            index(_uchars_,(unsigned char)(*t))-(char *)_uchars_);
  61. #endif
  62.     printf("tolower(%c)=%c\n", *t, tolower(*t));
  63.   }
  64.   putchar('\n');
  65.  
  66.   printf("Testing upper case letters\n");
  67.   for (t=_uchars_;*t;t++) {
  68.     printf("_fw_ctype_[%d]=%d\t",*t, ((THISCTYPEVAR + 1)[(unsigned char)*t]));
  69. #ifdef DEBUG
  70.     printf("index(%s,%c)=%d\t", _lchars_, *t, 
  71.            index(_lchars_,(unsigned char)(*t))-(char *)_lchars_);
  72. #endif
  73.     printf("islower(%c)=%d\t", *t, islower(*t));
  74.     printf("toupper(%c)=%c\t", *t, toupper(*t));
  75.     printf("isupper(%c)=%d\t", *t, isupper(*t));
  76. #ifdef DEBUG
  77.     printf("index(%s,%c)=%d\t", _uchars_, *t, 
  78.            index(_uchars_,(unsigned char)(*t))-(char *)_uchars_);
  79. #endif
  80.     printf("tolower(%c)=%c\n", *t, tolower(*t));
  81.   }
  82.   putchar('\n');
  83.   printf("strcmp(\"AA\",\"BB\")=%d\n",strcmp("AA","BB"));
  84.   printf("strcmp(\"{}\",\"Σhnlich\")=%d\n",strcmp("{}","Σhnlich"));
  85.   printf("strcmp(\"   \",\"Σhnlich\")=%d\n",strcmp("   ","Σhnlich"));
  86.   exit(0);
  87. }
  88.